import { request } from '@/utils/request'
import type {KnowledgeParams,KnowledgePage,PageParams,DoctorPage,FollowType,Attention,topDep,Image,ConsultOrderPreParams,ConsultOrderPreData,PartialConsult,ConsultOrderItem, ConsultOrderListParams, ConsultOrderPage} from '@/types/consult'
// 获取百科文章列表
export const getKnowledgePage=(params:KnowledgeParams)=> 
    request<KnowledgePage>('/patient/home/knowledge','GET',params)
// 获取医生列表
export const getDoctorPage=(params:PageParams)=> 
    request<DoctorPage>('/home/page/doc','GET',params)
// 关注
export const followOrUnfollow=(id:string,type:FollowType='doc')=> 
    request<Attention>('/like','POST',{id,type})
// 获取所有科室
export const getAllDep=()=>request<topDep[]>('/dep/all',"GET")
// 更新图片
export const updateImage=(file:File)=>{
    const fd=new FormData()
    fd.append('file',file)
    return request<Image>('/upload','POST',fd)
}
// 获取订单的信息
export const getConsultOrderPre =(params:ConsultOrderPreParams)=>request<ConsultOrderPreData>('/patient/consult/order/pre','GET',params)
// 获取订单号
export const getConsultOrderId =(data:PartialConsult)=>request<{id:string}>('/patient/consult/order','POST',data)
// 获取支付url
export const getConsultOrderPayUrl =(params:{
    paymentMethod:0 | 1
    orderId:string
    payCallback:string
})=>request<{payUrl:string}>('/patient/consult/pay','POST',params)
// 查询订单详情信息
export const getConsultOrderDetail=(orderId:string)=>request<ConsultOrderItem>('/patient/consult/order/detail','GET',{orderId})
// 查看处方
export const getPrescriptionPic=(id:string)=>request<{url:string}>(`/patient/consult/prescription/${id}`,'GET')
// 评价
export const evaluateConsultOrder =(data:{
    docId:string
    orderId:string
    score:number
    content:string
    anonymousFlag:0 | 1
})=>request('/patient/order/evaluate','POST',data)
// 问诊记录-订单列表
export const getConsultOrderList =(params:ConsultOrderListParams)=>
    request<ConsultOrderPage>('/patient/consult/order/list','GET',params)
// 取消订单
export const cancelOrder =(id:string)=>request(`/patient/order/cancel/${id}`,'PUT')
// 删除订单
export const deleteOrder =(id:string)=>request(`/patient/order/${id}`,"DELETE")